package com.hyt.it.ogt.kq.main;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import com.hyt.it.ogt.kq.service.gov.service.IProgressService;
import com.hyt.it.ogt.kq.service.gov.websocket.ProgressWebsocket;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * 启动类
 *
 * @author liuq
 */
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"com.hyt"})
@EnableHystrixDashboard
@EnableHystrix
@EnableCaching
@EnableAsync
@MapperScan(basePackages = {"com.hyt.**.mapper", "com.hyt.it.ogt.cj.mapper"})
@ComponentScan(basePackages = {"com.hyt"}, excludeFilters = {
        @ComponentScan.Filter(type = FilterType.REGEX, pattern = "com.hyt.exception.handler.GlobalExceptionHandler")
})
@Slf4j
public class Application {

    /**
     * 启动类main方法
     *
     * @param args args
     */
    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(Application.class, args);
        ProgressWebsocket.setIProgressService(run.getBean(IProgressService.class));
        ConfigurableEnvironment environment = run.getEnvironment();
        log.info("swagger访问地址：http://localhost:{}/doc.html", environment.getProperty("server.port"));
    }
}
